package com.minsf.springbootinit.dcl;

import java.util.concurrent.TimeUnit;

/**
 * @Description 饿汉式
 * @Author minify
 * @Date 2024/1/2 21:49
 * @Project oj-backend
 */
public class Lazy {

    private volatile static Lazy instance = null;


    private Lazy() {
        System.out.println("当前线程为：" + Thread.currentThread().getName());
    }

    public static Lazy getInstance() {
        if (instance == null) {
            synchronized (Lazy.class) {
                if (instance == null) {
                    instance = new Lazy();
                }
            }
        }
        return instance;
    }
}
